Skip to content

FIX: uum 138143 button press points for stickcontrol and vector2 add functionality#2411

Open
Darren-Kelly-Unity wants to merge 37 commits into
developfrom
bugfix/uum-138143-button-press-points-for-stickcontrol-and-vector2-add-functionality
Open

FIX: uum 138143 button press points for stickcontrol and vector2 add functionality#2411
Darren-Kelly-Unity wants to merge 37 commits into
developfrom
bugfix/uum-138143-button-press-points-for-stickcontrol-and-vector2-add-functionality

Conversation

@Darren-Kelly-Unity
Copy link
Copy Markdown
Collaborator

@Darren-Kelly-Unity Darren-Kelly-Unity commented Apr 29, 2026

Purpose of this PR

Fixes UUM-138143InputAction.IsPressed() / in-progress style checks could fire at the wrong effective magnitude for Vector2 / stick bindings when developers set pressPoint on the control or on PressInteraction, instead of honoring those thresholds consistently.

Introduces IActuationPressPoint, implements it on ButtonControl, Vector2Control, and (via Vector2Control) StickControl, and threads pressPoint / pressPointOrDefault through InputAction, InputActionState, and InputControlExtensions so press-style polling matches the documented interaction defaults. Adds ActuationPressPointTests and refreshes RespondingToActions.md.

Release Notes

  • UUM-138143InputAction.IsPressed() (and related press / in-progress behavior) for actions bound to Vector2Control and StickControl now respects per-control pressPoint and binding PressInteraction.pressPoint, aligning with ButtonControl and fixing incorrect early triggers when rewriting default interaction thresholds.

Functional Testing status

  • Automated: new ActuationPressPointTests and updates in CoreTests_Actions / CoreTests_Controls cover press-point actuation paths.
  • Manual: repro project IN-136917 / scene Input Bug from the ticket; verify console no longer shows IsPressed before processed magnitude reaches the configured press threshold for vector / stick cases.

Performance Testing Status

I have added performance testing for the hot path methods that Hakan flagged and I don't see any major issues when comparing. There is a slight increase in cost of performance of about 0.1ms for 1000 iterations on the GetActuationPressThreshold() method that was asked to be checked.

No new per-frame allocations identified in scope.

Overall Product Risks

Technical Risk: 2 — Touches InputActionState and widely used press APIs; edge cases around magnitude, deadzones, and interactions need regression confidence.

Halo Effect: 2 — Any title using IsPressed / WasPressedThisFrame on Vector2 / stick actions may see timing changes until bindings are tuned; behavior is intended to match documented pressPoint semantics.

Class diagram

Git range analyzed: origin/develop...HEAD (4 commits).

Mermaid class diagram (GitHub)
classDiagram
  direction TB

  class IActuationPressPoint {
    <<interface>>
    +pressPoint
    +pressPointOrDefault
  }

  class ButtonControl {
    +pressPoint
    +pressPointOrDefault
  }

  class Vector2Control {
    +pressPoint
    +pressPointOrDefault
  }

  class StickControl {
  }

  class InputAction {
    +IsPressed()
    +WasPressedThisFrame()
    +WasReleasedThisFrame()
  }

  class InputActionState {
  }

  class InputControlExtensions {
    <<static>>
  }

  IActuationPressPoint <|.. ButtonControl
  IActuationPressPoint <|.. Vector2Control
  Vector2Control <|-- StickControl
  InputAction --> InputActionState : uses
  InputControlExtensions ..> IActuationPressPoint : pressPointOrDefault
Loading

Documentation Impact

Changes analyzed: origin/develop...HEAD (4 commits).

User-facing: New public IActuationPressPoint; InputAction press-helper remarks/behavior; ButtonControl, Vector2Control, StickControl docs around pressPoint; RespondingToActions.md updated for polling vs pressPoint.

Documentation updates in this PR

  • RespondingToActions.md — Clarifies IsPressed / frame helpers vs interactions and pressPoint; review wording and cross-refs after merge.

Follow-up (optional)

  • If QA/docs want a dedicated IActuationPressPoint callout in a control reference page, add a short subsection and link from Responding to Actions.

Jira (fetched via MCP): Bug, In Progress, TBD priority, assignee Darren Kelly, label Input-Actions. Ticket summary: InputAction.IsPressed() and IsInProgress() triggers on wrong values when rewriting the default values of Vector2 interactions.

@u-pr
Copy link
Copy Markdown
Contributor

u-pr Bot commented Apr 29, 2026

⚠️ Review skipped — this PR is too large to process.

The diff contains approximately 325,668 tokens (~977,005 characters), which exceeds the maximum limit of 150,000 tokens.

Please consider splitting this PR into smaller, focused changes.

🤖 Helpful? 👍/👎

@codecov-github-com
Copy link
Copy Markdown

codecov-github-com Bot commented Apr 29, 2026

Codecov Report

Attention: Patch coverage is 72.14137% with 134 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...sets/Tests/InputSystem/ActuationPressPointTests.cs 57.46% 131 Missing ⚠️
Assets/Tests/InputSystem/CoreTests_Actions.cs 97.24% 3 Missing ⚠️
@@             Coverage Diff             @@
##           develop    #2411      +/-   ##
===========================================
+ Coverage    78.13%   78.22%   +0.09%     
===========================================
  Files          483      762     +279     
  Lines        98770   140555   +41785     
===========================================
+ Hits         77169   109946   +32777     
- Misses       21601    30609    +9008     
Flag Coverage Δ
inputsystem_MacOS_2022.3_project 75.31% <70.28%> (-0.10%) ⬇️
inputsystem_MacOS_6000.0_project 77.19% <70.28%> (-0.11%) ⬇️
inputsystem_MacOS_6000.3_project 77.19% <70.28%> (-0.08%) ⬇️
inputsystem_MacOS_6000.4_project 77.20% <70.28%> (-0.08%) ⬇️
inputsystem_MacOS_6000.5_project 77.23% <70.28%> (-0.09%) ⬇️
inputsystem_MacOS_6000.6_project 77.23% <70.28%> (-0.08%) ⬇️
inputsystem_Ubuntu_2022.3_project 75.21% <70.28%> (-0.10%) ⬇️
inputsystem_Ubuntu_6000.0_project 77.10% <70.28%> (-0.11%) ⬇️
inputsystem_Ubuntu_6000.3_project 77.10% <70.28%> (-0.08%) ⬇️
inputsystem_Ubuntu_6000.4_project 77.11% <70.28%> (-0.08%) ⬇️
inputsystem_Ubuntu_6000.5_project 77.14% <70.28%> (-0.09%) ⬇️
inputsystem_Ubuntu_6000.6_project 77.14% <70.28%> (-0.08%) ⬇️
inputsystem_Windows_2022.3_project 75.43% <70.28%> (-0.10%) ⬇️
inputsystem_Windows_6000.0_project 77.32% <70.28%> (-0.11%) ⬇️
inputsystem_Windows_6000.3_project 77.32% <70.28%> (-0.08%) ⬇️
inputsystem_Windows_6000.4_project 77.32% <70.28%> (-0.08%) ⬇️
inputsystem_Windows_6000.5_project 77.37% <70.28%> (-0.08%) ⬇️
inputsystem_Windows_6000.6_project 77.37% <70.28%> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
Assets/Tests/InputSystem/CoreTests_Controls.cs 99.80% <100.00%> (-0.02%) ⬇️
...tsystem/InputSystem/Runtime/Actions/InputAction.cs 92.12% <100.00%> (ø)
...em/InputSystem/Runtime/Actions/InputActionState.cs 92.42% <100.00%> (ø)
...m/Runtime/Actions/Interactions/PressInteraction.cs 88.60% <ø> (ø)
...stem/InputSystem/Runtime/Controls/ButtonControl.cs 88.37% <100.00%> (ø)
...tSystem/Runtime/Controls/InputControlExtensions.cs 76.12% <100.00%> (ø)
...ystem/InputSystem/Runtime/Controls/StickControl.cs 100.00% <ø> (ø)
...tem/InputSystem/Runtime/Controls/Vector2Control.cs 100.00% <100.00%> (ø)
Assets/Tests/InputSystem/CoreTests_Actions.cs 98.89% <97.24%> (+0.48%) ⬆️
...sets/Tests/InputSystem/ActuationPressPointTests.cs 57.46% <57.46%> (ø)

... and 242 files with indirect coverage changes

ℹ️ Need help interpreting these results?

@Darren-Kelly-Unity Darren-Kelly-Unity changed the title Bugfix/uum 138143 button press points for stickcontrol and vector2 add functionality FIX: uum 138143 button press points for stickcontrol and vector2 add functionality Apr 29, 2026
…-stickcontrol-and-vector2-add-functionality

# Conflicts:
#	Packages/com.unity.inputsystem/InputSystem/Runtime/Controls/InputControlExtensions.cs
Copy link
Copy Markdown
Collaborator

@ekcoh ekcoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Darren-Kelly-Unity Would it be possible to get rid of all the whitespace diffs on this PR? It would be much easier to review if this was corrected.

Comment thread Packages/com.unity.inputsystem/InputSystem/Runtime/Actions/InputAction.cs Outdated
/// </summary>
public float pressPointOrDefault => pressPoint > 0 ? pressPoint : s_GlobalDefaultButtonPressPoint;

float IActuationPressPoint.pressPoint => pressPoint;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me it look odd that presspoint (new and previous is modelled on the control instead of on the interaction), what happens when two interactions with different press points bind to the same button?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed this with AI but you can see in InputActionState.GetActuationPressThreshold() that:

There is an order, it is control-first for device semantics, interaction when the control does not override, then the default settings value.

AI Brief answer:

"Press threshold on the control models the physical control’s default; each binding’s interaction can still use its own press point when the control does not fix one, and separate bindings to the same button keep separate interaction state and thresholds unless the control’s own pressPoint is set, in which case that value wins for unified resolution."

There is also a longer text/ investigation done if you want to see that too?

Comment thread Packages/com.unity.inputsystem/InputSystem/Runtime/Controls/ButtonControl.cs Outdated
Copy link
Copy Markdown
Collaborator

@ekcoh ekcoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed, I had quite a lot of questions and some remaining from last review so leaving this as comment-only for now.

/// <summary>
/// Effective press threshold: <see cref="pressPoint"/> when set, otherwise the global default.
/// </summary>
float pressPointOrDefault { get; }
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need two? Would it be better to have one, e.g. pressPoint that returns default if not having a layout-configured press threshold? Since both go through an interface anyway I wouldn't expect it to be an optimisation?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just following the format that was already there for now, not sure about removing one as it was publicly available before.

Comment thread Packages/com.unity.inputsystem/InputSystem/Controls/IActuationPressPoint.cs Outdated
if (interactionState.totalTimeoutCompletionTimeRemaining > 0)
{
return (interactionState.totalTimeoutCompletionDone + timerCompletion * interactionState.timerDuration) /
return (interactionState.totalTimeoutCompletionDone + timerCompletion * interactionState.timerDuration) /
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like pure formatting diff and could be reverted

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have left a few of the formatting changes in for now as they are correct. This one also looks ok I think?

Comment thread Packages/com.unity.inputsystem/InputSystem/Runtime/Actions/InputActionState.cs Outdated
if (count == 0)
return null;
var start = bindingStateForInteractions->interactionStartIndex;
for (var i = 0; i < count; ++i)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corner case: I am confused around this code, it looks like if there are multiple PressInteractions it will return the pressPoint of the first one? While this is probably OK, it might be good documenting it on PressInteraction or similar?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, It was already this way for buttonControl's previously. I have added documentation for this now.

private float GetActuationPressThreshold(InputControl control, BindingState* bindingStatePtr)
{
var bindingForInteractions = GetBindingStateForInteractionParameters(bindingStatePtr);
var explicitPress = TryGetExplicitPressInteractionPressPoint(bindingForInteractions);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cost is paid also when the first return is triggered. Did you compare any performance benchmark for this to rule out that these changes do not regress performance for various press configurations? Might be worthwhile to check since we have a combination here of virtual calls, fixed overhead evaluation, type checks etc.

{
if (control is ButtonControl button)
buttonPressPoint = button.pressPointOrDefault;
if (control is IActuationPressPoint actuation)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beware that this type check might be more expensive than the previous. Previously checking against a specific type, now checking for multiple types implementing interface. Its probably negligible but might we worth checking since hot-path.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added performance tests for this vs the legacy system, we can maybe chat about it in a call if that makes sense but I don't see much change here.

Comment thread Packages/com.unity.inputsystem/InputSystem/Runtime/Controls/Vector2Control.cs Outdated
Comment thread Packages/com.unity.inputsystem/InputSystem/Runtime/Controls/Vector2Control.cs Outdated
…ctor2Control.cs

Co-authored-by: Håkan Sidenvall <hakan.sidenvall@unity3d.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants